package com.hiyee.platform.controller;

import com.hiyee.platform.response.PageListResult;
import com.hiyee.platform.response.ResponseJsonResult;
import com.hiyee.platform.pojo.bo.WeatherListBO;
import com.hiyee.platform.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

@RestController
@RequestMapping("/weather")
public class WeatherController extends BaseController{

    @Autowired
    WeatherService weatherService;

    @PostMapping("/list")
    public ResponseJsonResult getList(@RequestBody @Valid WeatherListBO weatherListBO, BindingResult bindingResult) {
        if(bindingResult.hasErrors()) {
            return ResponseJsonResult.error(this.getError(bindingResult));
        }
        PageListResult dataList = weatherService.getList(weatherListBO);
        return ResponseJsonResult.success(dataList);
    }
}